package com.xzh.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xzh.model.Schedules;
import com.xzh.model.search.ScheduleDao;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface SchedulesMapper extends BaseMapper<Schedules> {
    default Page<Schedules> selectAll(Page<Schedules> page, Schedules schedules){
        LambdaQueryWrapper<Schedules> qw = Wrappers.lambdaQuery(schedules);
        if(schedules.getScheduleId() != null){
            qw.eq(Schedules::getScheduleId, schedules.getScheduleId());
        }
        if(schedules.getWeekDay() != null){
            qw.like(Schedules::getWeekDay, schedules.getWeekDay());
        }
        if(schedules.getStatus() != null){
            qw.like(Schedules::getStatus, schedules.getStatus());
        }
        return selectPage(page, qw);
    }

    List<ScheduleDao> selsectList();
}
